package com.apps.sdses.flink141.test;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import java.util.List;

/**
 * @author jiwei
 * @description
 * @date 2024/1/15 14:50
 */
public class JsonNodeTest02 {
    public static void main(String[] args) throws JsonProcessingException {

//        String jsonStr = "{\"id\":\"1746781241197830145\",\"name\":\"test_job_subscription_02\",\"sourceType\":\"KAFKA\",\"sourceTopics\":[\"drity_data_source\"],\"targetType\":\"WEBHOOK\",\"targetInfo\":{\"url\":\"http://192.168.102.151:28087/api/test\",\"testUrl\":\"\",\"method\":\"POST\",\"headers\":[[\"key1\",\"value1\"],[\"key2\",\"value2\"]]},\"createTime\":1705300137484,\"directoryId\":\"1746778888902123521\"}";
        String headers = "{\"headers\":[[\"key1\",\"value1\"],[\"key2\",\"value2\"]]}";
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode jsonNodes = mapper.readValue(headers, ObjectNode.class);
        JsonNode node = jsonNodes.get("headers");
        System.out.println(node);
        System.out.println(node.getNodeType());


        String h2 = "[[\"key1\",\"value1\"],[\"key2\",\"value2\"]]";
        List<List<String>> list = mapper.readValue(h2, List.class);
        System.out.println(list.get(0).toString());


    }
}
